function rem() {
    document.documentElement.style.fontSize = document.documentElement.clientWidth / 4 + 'px'
}
rem()
window.onresize = rem

$(function () {
    document.addEventListener("touchmove", function (e) {
        e.preventDefault()
    }, {
        passive: false
    });
    var box = new IScroll('#box', {
        probeType: 2,
    })

    var startY = box.maxScrollY

    box.on('scroll', function () {
        var refreshHeight = $('.refresh').height()

        if (this.y >= refreshHeight) {
            $('.refresh').html('松开刷新').addClass('aaa')
            this.minScrollY = refreshHeight
            console.log(refreshHeight)
        }

        if (this.y <= -(this.scrollerHeight-this.wrapperHeight+refreshHeight)) {
            $('.more').html('松开刷新').addClass('bbb')
            
          
            this.maxScrollY = -(this.scrollerHeight-this.wrapperHeight+refreshHeight);
        }
    })

    box.on('scrollEnd', function () {
        if ($('.refresh').hasClass('aaa')) {
            $('.refresh').html('leadling')

            setTimeout(function () {
                var oLi = $('<div>数据加载完毕</div>')
                oLi.appendTo('.shuju')
                $('.refresh').html('下拉刷新').removeClass('aaa')
                box.refresh()
            }, 2000)
        }

        if($(".more").hasClass("bbb")){
            // 3.正在加载提示  
            $(".more").html("正在加载数据，请稍后。。。");
            // 4.加载数据到页面---为了模拟加载数据等待场景，我们使用事件延迟
            setTimeout(function(){
                var oLi = $("<div>数据加载完毕</div>")
                oLi.appendTo('.shuju')
                
                //5.隐藏提示框
                box.refresh();
                //6.初始化提示框
                $(".more").html("上拉刷新").removeClass("bbb");
            },2000);
        }       

    })

})